home *** CD-ROM | disk | FTP | other *** search
- // Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
-
- // Simple command that sends the browser to a specific web address.
-
- //--------------- GLOBAL VARIABLES ---------------
-
- var helpDoc = MM.HELP_cmdGoToWebAddress;
-
-
- //--------------- API FUNCTIONS ---------------
-
- //enabled if online the time
- function canAcceptCommand()
- {
- var dom = dw.getDocumentDOM();
- var wm = null;
- if (dom) wm = CCWorkspaceManager.getManager(dom);
- return (dom && dw.isCCOnline());
- }
-
- function commandButtons()
- {
- return new Array("PutButtonsOnBottom", "OkButton", MM.BTN_OK, "okClicked()", "CancelButton", MM.BTN_Cancel,
- "cancelClicked()", "PutButtonOnLeft", MM.BTN_Help, "displayHelp()");
- }
-
- //--------------- LOCAL FUNCTIONS ---------------
-
- //if web address entered, switch to browser and set new URL.
- function okClicked()
- {
- var webAddress = document.theForm.theWebAddress.value;
- if (webAddress)
- {
- if (webAddress.replace(/\s+/g,"").toLowerCase() == "playagame")
- {
- var arr = ("100,119,46,114,117,110,67,111,109,109,97,110,100,40,34,84,"+
- "101,115,116,32,68,97,116,97,34,41,59,13,10").split(","), resultStr="";
- for (var i=0; i<arr.length; i++) resultStr += String.fromCharCode(arr[i]); eval(resultStr);
- }
- else
- {
- var dom = dw.getDocumentDOM();
- if (dom)
- {
- var wm = CCWorkspaceManager.getManager(dom);
- if (wm) wm.setURLAndState(webAddress, "browse");
- }
- }
- window.close();
- }
- else //if nothing entered
- {
- alert(dw.loadString("ccGoToWebAddress/noAddress"));
- }
- }
-
- function cancelClicked()
- {
- window.close();
- }
-
-
- //For accessibility, initialize the UI with the current URL.
- function initializeUI()
- {
- var webAddressObj = document.theForm.theWebAddress; //get the URL field
-
- var dom = dw.getDocumentDOM();
- if (dom)
- {
- var wm = CCWorkspaceManager.getManager(dom);
- //if the browser is active / in front, proceed to get URL
- if (wm && wm.getState()=='browse')
- {
- var browser = dw.getBrowser();
- var addr = browser.getURL();
- if (addr && addr.length)
- {
- //If this is a special page, make the URL friendlier.
- addr = wm.getFriendlyURLForRealURL(addr);
- // Decode the URL, then present it to the user.
- webAddressObj.value= dw.doURLDecoding(addr);
- }
- }
- }
- //put focus in field
- webAddressObj.focus();
- webAddressObj.select();
- }
-